<template>
  <div class="box">
    <div class="blockBox">
      <div class="selectBox">
        <div class="selectText">时间段</div>
        <el-select v-model="valueTime" placeholder="请选择" style="width: 83%" @change="selectChangeTime(item)">
          <el-option
            v-for="item in optionsTime"
            :key="item.id"
            :label="item.surveyName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </div>
    </div>

    <div class="blockBox">
      <Title v-if="isTitle" ref="titleData" :filterCondition="selectTime" :type="type"></Title>
    </div>
    <div class="blockBox">
<!--      <div class="selectBox">-->
<!--        <div class="selectText">学段</div>-->
<!--        <el-select v-model="valuePeriod1" placeholder="请选择" style="width: 85%" @change="selectChangePeriod">-->
<!--          <el-option-->
<!--            v-for="item in optionsPeriod"-->
<!--            :key="item.id"-->
<!--            :label="item.name"-->
<!--            :value="item.id"-->
<!--          >-->
<!--          </el-option>-->
<!--        </el-select>-->
<!--      </div>-->
      <!-- 整体完成数曲线图-->
      <LineEcharts v-if="isShow2" :echartsData="echartsData2" :echartsId="echartsId[1]"
                   :echartsType="echartsType[0]"></LineEcharts>
      <!--      <div style="border-bottom: 1px solid #000000;width: 100%"></div>-->
      <!-- 学校完成数排名 -->
      <LineEcharts v-if="isShow6" :echartsData="echartsData6" :echartsId="echartsId[5]"
                   :echartsType="echartsType[1]"
                   :isMore="true"
                   @dialogTableClick="dialogTableClick('classTotal')"
      ></LineEcharts>
      <!-- 学校完成数排名(横轴完成数、纵轴学校)-->
      <!--      <LineEcharts v-if="isShow8" :echartsData="echartsData8" :echartsId="echartsId[7]"-->
      <!--                   :echartsType="echartsType[1]"></LineEcharts>-->
    </div>
    <div class="blockBox">
<!--      <div class="selectBox">-->
<!--        <div class="selectText">学段</div>-->
<!--        <el-select v-model="valuePeriod2" placeholder="请选择" style="width: 85%" @change="selectChangePeriod1">-->
<!--          <el-option-->
<!--            v-for="item in optionsPeriod"-->
<!--            :key="item.id"-->
<!--            :label="item.name"-->
<!--            :value="item.id"-->
<!--          >-->
<!--          </el-option>-->
<!--        </el-select>-->
<!--      </div>-->

      <!-- 完成率曲线图-->
      <LineEcharts v-if="isShow1" :echartsData="echartsData1" :echartsId="echartsId[0]" :echartsType="echartsType[0]"
                   :yAxisFormatter="true"></LineEcharts>
      <!-- 学校完成率排名 -->
      <LineEcharts v-if="isShow7" :echartsData="echartsData7" :echartsId="echartsId[6]" :echartsType="echartsType[1]"
                   :yAxisFormatter="true"
                   :isMore="true"
                   @dialogTableClick="dialogTableClick('classRate')"></LineEcharts>
      <!-- 学校完成率排名(横轴完成数、纵轴学校)-->
      <!--      <LineEcharts v-if="isShow9" :echartsData="echartsData9" :echartsId="echartsId[8]" :echartsType="echartsType[1]"-->
      <!--                   :yAxisFormatter="true"></LineEcharts>-->
      <!--      <Map ref="mapData" :city="'liuzhoushi'" :filterCondition="selectTime" :studentLevel="valuePeriod2"></Map>-->
    </div>

    <!--    <div class="blockBox">-->
    <!--      <div class="selectBox">-->
    <!--        <div class="selectText">性别</div>-->
    <!--        <el-select v-model="valueSex" placeholder="请选择" style="width: 85%" @change="selectChangeSex('小学')">-->
    <!--          <el-option-->
    <!--            v-for="item in optionsSex"-->
    <!--            :key="item.id"-->
    <!--            :label="item.name"-->
    <!--            :value="item.id"-->
    <!--          >-->
    <!--          </el-option>-->
    <!--        </el-select>-->
    <!--      </div>-->
    <!--      <ComplexBar v-if="isShow10" :echartsData="echartsData10" :echartsId="echartsId[9]"></ComplexBar>-->
    <!--    </div>-->
    <!--    <ComplexBar v-if="isShow14" :echartsData="echartsData10" :echartsId="echartsId[10]"></ComplexBar>-->
    <!--    <div class="blockBox">-->
    <!--      <div class="selectBox">-->
    <!--        <div class="selectText">因子</div>-->
    <!--        <el-select v-model="value" placeholder="请选择" style="width: 85%" @change="selectChange('小学')">-->
    <!--          <el-option-->
    <!--            v-for="item in options"-->
    <!--            :key="item.id"-->
    <!--            :label="item.title"-->
    <!--            :value="item.id"-->
    <!--          >-->
    <!--          </el-option>-->
    <!--        </el-select>-->
    <!--      </div>-->
    <!--      &lt;!&ndash;小学各区因子统计&ndash;&gt;-->
    <!--      <ComplexBar v-if="isShow12" :echartsData="echartsData12" :echartsId="echartsId[11]"></ComplexBar>-->
    <!--      &lt;!&ndash;小学各学校因子统计&ndash;&gt;-->
    <!--      <ComplexBar v-if="isShow13" :echartsData="echartsData13" :echartsId="echartsId[12]"></ComplexBar>-->
    <!--      &lt;!&ndash;小学各年级因子统计&ndash;&gt;-->
    <!--      <ComplexBar v-if="isShow14" :echartsData="echartsData14" :echartsId="echartsId[13]"></ComplexBar>-->
    <!--    </div>-->

    <!--    <div class="blockBox">-->
    <!--      <div class="selectBox">-->
    <!--        <div class="selectText">性别</div>-->
    <!--        <el-select v-model="valueSex1" placeholder="请选择" style="width: 85%" @change="selectChangeSex('初中')">-->
    <!--          <el-option-->
    <!--            v-for="item in optionsSex"-->
    <!--            :key="item.id"-->
    <!--            :label="item.name"-->
    <!--            :value="item.id"-->
    <!--          >-->
    <!--          </el-option>-->
    <!--        </el-select>-->
    <!--      </div>-->
    <!--      <ComplexBar v-if="isShow15" :echartsData="echartsData15" :echartsId="echartsId[14]"></ComplexBar>-->
    <!--    </div>-->
    <!--    <div class="blockBox">-->
    <!--      <div class="selectBox">-->
    <!--        <div class="selectText">因子</div>-->
    <!--        <el-select v-model="value1" placeholder="请选择" style="width: 85%" @change="selectChange('初中')">-->
    <!--          <el-option-->
    <!--            v-for="item in options1"-->
    <!--            :key="item.id"-->
    <!--            :label="item.title"-->
    <!--            :value="item.id"-->
    <!--          >-->
    <!--          </el-option>-->
    <!--        </el-select>-->
    <!--      </div>-->
    <!--      &lt;!&ndash;初中各区因子统计&ndash;&gt;-->
    <!--      <ComplexBar v-if="isShow16" :echartsData="echartsData16" :echartsId="echartsId[15]"></ComplexBar>-->
    <!--      &lt;!&ndash;初中各学校因子统计&ndash;&gt;-->
    <!--      <ComplexBar v-if="isShow17" :echartsData="echartsData17" :echartsId="echartsId[16]"></ComplexBar>-->
    <!--      &lt;!&ndash;初中各年级因子统计&ndash;&gt;-->
    <!--      <ComplexBar v-if="isShow18" :echartsData="echartsData18" :echartsId="echartsId[17]"></ComplexBar>-->
    <!--    </div>-->

    <div class="blockBox">
      <!--      <div v-show="!isMore" class="moreIconBox" @click="isMore = !isMore">-->
      <!--        <div class="moreIcon">-->
      <!--          <i v-show="!isMore" class="el-icon-caret-bottom">更多</i>-->
      <!--        </div>-->
      <!--      </div>-->
      <div class="selectBox">
        <div class="selectText">量表</div>
        <el-select v-model="valueSchool" placeholder="请选择" style="width: 85%" @change="selectChangeSex('更多')">
          <el-option
            v-for="item in optionsSchool"
            :key="item.template_id"
            :label="item.template_name"
            :value="item.template_id"
          >
          </el-option>
        </el-select>
      </div>
      <div class="selectBox">
        <div class="selectText">性别</div>
        <el-select v-model="valueSex2" placeholder="请选择" style="width: 85%" @change="selectChangeSex('更多')">
          <el-option
            v-for="item in optionsSex"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </div>
      <ComplexBar v-if="isShow19" :echartsData="echartsData19" :echartsId="echartsId[18]"></ComplexBar>
<!--      <div class="selectBox">-->
<!--        <div class="selectText">因子</div>-->
<!--        <el-select v-model="value2" placeholder="请选择" style="width: 85%" @change="selectChange('更多')">-->
<!--          <el-option-->
<!--            v-for="item in options3"-->
<!--            :key="item.id"-->
<!--            :label="item.title"-->
<!--            :value="item.id"-->
<!--          >-->
<!--          </el-option>-->
<!--        </el-select>-->
<!--      </div>-->
      <ComplexBar v-if="isShow20" :echartsData="echartsData20" :echartsId="echartsId[19]"></ComplexBar>
      <!--      <ComplexBar v-if="isShow21" :echartsData="echartsData21" :echartsId="echartsId[20]"></ComplexBar>-->
      <!--      <ComplexBar v-if="isShow22" :echartsData="echartsData22" :echartsId="echartsId[21]"></ComplexBar>-->
      <!--      <div v-show="isMore" class="moreIconBox" @click="isMore = !isMore">-->
      <!--        <div class="moreIcon">-->
      <!--          <i v-show="isMore" class="el-icon-caret-top">收起</i>-->
      <!--        </div>-->
      <!--      </div>-->
    </div>

    <!--完成数-->
    <Table :dataType="'total'" :dialogTableVisible="dialogTableVisibleClassTotal" :filterCondition="selectTime"
           :interfaceType="'8'"
           :studentLevel="valuePeriod1" :title="'该校各年纪完成数排名'" :type="type"
           @closeDialog="closeDialog('classTotal')"></Table>

    <!--完成率-->
    <Table :dataType="'rate'" :dialogTableVisible="dialogTableVisibleClassRate" :filterCondition="selectTime"
           :interfaceType="'9'"
           :studentLevel="valuePeriod2" :title="'该校各年纪完成率排名'" :type="type"
           @closeDialog="closeDialog('classRate')"></Table>
  </div>
  <!--  </div>-->
</template>

<script>
import ScaleManage from './scalemanage.vue'
import LineEcharts from './lineEcharts.vue'
import Map from './map.vue'
import ComplexBar from './complexBar.vue'
import Title from './title.vue'
import Table from './table.vue'
import {getStore, setStore} from '@/util/store'
import {
  getDateList,
  getScaleList,
  getTemplateList,
  getUserInfoNew, statisticClassesCountAndRate,
  statisticDayCount,
  statisticDayRate,
  statisticFactorLevel,
  statisticLevelCountByFactor,
  statisticLevelRate,
  statisticSchoolCountAndRate
} from '@/api/platform/templateManage'

export default {
  components: {
    ScaleManage,
    LineEcharts,
    Title, ComplexBar,
    Map,Table
  },
  data() {
    return {
      isMore: false,
      echartsType: ['line', 'bar'],//line：折线图，bar：柱状图
      echartsId: ['main1', 'main2', 'main3', 'main4', 'main5', 'main6', 'main7', 'main8', 'main9', 'main10', 'main11', 'main12', 'main13', 'main14', 'main15', 'main16', 'main17', 'main18', 'main19', 'main20', 'main21', 'main22', 'main23', 'main24', 'main25'],
      type: '4',
      echartsData1: {},
      echartsData2: {},
      echartsData3: {},
      echartsData4: {},
      echartsData5: {},
      echartsData6: {},
      echartsData7: {},
      echartsData8: [],
      echartsData9: {},
      echartsData10: {},
      echartsData11: {},
      echartsData12: {},
      echartsData13: {},
      echartsData14: {},
      echartsData15: {},
      echartsData16: {},
      echartsData17: {},
      echartsData18: {},
      echartsData19: {},
      echartsData20: {},
      echartsData21: {},
      echartsData22: {},
      isShow1: false,
      isShow2: false,
      isShow3: false,
      isShow4: false,
      isShow5: false,
      isShow6: false,
      isShow7: false,
      isShow8: false,
      isShow9: false,
      isShow10: false,
      isShow11: false,
      isShow12: false,
      isShow13: false,
      isShow14: false,
      isShow15: false,
      isShow16: false,
      isShow17: false,
      isShow18: false,
      isShow19: false,
      isShow20: false,
      isShow21: false,
      isShow22: false,

      options: [{title: '', id: ''}],
      options1: [{title: '', id: ''}],
      options2: [{title: '', id: ''}],
      options3: [{title: '', id: ''}], //更多  因子列表
      optionsTime: [{surveyName: '', id: ''}],//时间
      optionsPeriod: [{name: '全市', id: ''},
        {name: '幼儿园', id: '幼儿园'},
        {name: '小学', id: '小学'},
        {name: '初中', id: '初中'},
        {name: '高中', id: '高中'}
      ],//学段
      optionsSex: [
        {name: '全部', id: ''},
        {name: '男', id: '男'},
        {name: '女', id: '女'},
      ],//学段
      optionsSchool: [],
      value: '', //小学因子
      value1: '', //中学因子
      value2: '', //更多因子
      valueTime: '',//时间
      valuePeriod1: '', //整体数学段
      valuePeriod2: '', //整体率学段
      valueSex: '', //小学性别
      valueSex1: '', //中学生性别
      valueSchool: '', //更多中  选择学校
      valueSex2: '', //更多中  选择性别
      selectTime: {},
      dialogTableVisibleClassTotal:false,
      dialogTableVisibleClassRate:false,
      isTitle: false,
    }
  },
  created() {

    this.getUserInfo()
    // this.getData()
  },
  methods: {
    // 打开弹窗
    dialogTableClick(dataType) {
      console.log('打开弹窗', dataType)
      if (dataType == 'classTotal') {
        this.dialogTableVisibleClassTotal = true
        console.log('121212121212121212')
      } else if (dataType == 'classRate') {
        this.dialogTableVisibleClassRate = true
      }
    },
    closeDialog(dataType) {
      if (dataType == 'classTotal') {
        this.dialogTableVisibleClassTotal = false
      } else if (dataType == 'classRate') {
        this.dialogTableVisibleClassRate = false
      }
      console.log('父组件关闭弹窗')
    },
    async getData() {
      // 整体完成数曲线图
      await this.getStatisticDayCount()
      // 完成率曲线图
      await this.statisticDayRate()

      // 小学完成率
      // this.getStatisticLevelRate1()
      // 初中完成率
      // this.getStatisticLevelRate2()
      // 高中完成率
      // this.getStatisticLevelRate3()
      // 各区完成数排名柱图(完成数)
      await this.getStatisticAreaCountAndRate()
      // 各区完成数排名柱图(完成率)
      await this.getStatisticAreaCountAndRate1()
      // 学校完成数排名(横轴完成数、纵轴学校)（完成数）
      // await this.getStatisticSchoolCountAndRate()
      // 学校完成数排名(横轴完成数、纵轴学校)（完成率）
      // await this.getStatisticSchoolCountAndRate1()
      // 小学生心理健康量表各维度的统计
      // await this.getStatisticFactorLevel('小学')
      // 小学生 根据因子统计各个区等级数量
      // await this.getStatisticLevelCountByFactor1('小学')
      // 小学生 根据因子统计学校各个等级数量
      // await this.getStatisticLevelCountByFactor2('小学')
      // 小学生 根据因子统计各个年级各个等级数量
      // await this.getStatisticLevelCountByFactor3('小学')

      // 中学生的心理健康量表各维度的统计
      // await this.getStatisticFactorLevel('初中')
      // 中学生 根据因子统计各个区等级数量
      // await this.getStatisticLevelCountByFactor1('初中')
      // 中学生 根据因子统计学校各个等级数量
      // await this.getStatisticLevelCountByFactor2('初中')
      // 中学生 根据因子统计各个年级各个等级数量
      // await this.getStatisticLevelCountByFactor3('初中')

      // 中学生的心理健康量表各维度的统计  更多
      await this.getStatisticFactorLevelMore()
      // 中学生 根据因子统计各个区等级数量
      await this.getStatisticLevelCountByFactorMore1()
      // 中学生 根据因子统计学校各个等级数量
      // await this.getStatisticLevelCountByFactorMore2()
      // 中学生 根据因子统计各个年级各个等级数量
      // await this.getStatisticLevelCountByFactorMore3()


      await this.getTrue()
      console.log("0000000")

    },
    getTrue() {
      return new Promise(resolve => {
        this.isShow2 = true
        this.isShow6 = true
        // this.isShow8 = true
        this.isShow1 = true
        this.isShow7 = true
        // this.isShow9 = true
        // this.isShow10 = true
        // this.isShow12 = true
        // this.isShow13 = true
        // this.isShow14 = true
        // this.isShow15 = true
        // this.isShow16 = true
        // this.isShow17 = true
        // this.isShow18 = true
        this.isShow19 = true
        this.isShow20 = true
        // this.isShow21 = true
        // this.isShow22 = true
        console.log('111111111111')
        resolve();
      })

      // this.isShow6 = true
    },
    getUserInfo() {
      let params = {
        userType: '5'
      }
      getUserInfoNew(params).then(res => {
        if (res.data.code === 200) {
          setStore({name: 'newUserInfo', content: res.data.data})
          this.isTitle = true
          // commit('SET_NEW_USER_INFO', res.data.data);
          // let b = getStore({name: 'newUserInfo'})
          // console.log('bbbbbbbbb',b)
          // console.log('获取UserInfo', res.data)
          // 获取时间
          this.getDateList()
          // 获取因子列表
          this.getScaleList('151', '1') //小学
          this.getScaleList('150', '1') //初中
          // 获取量表下拉数据
          this.getTemplateList()

          // this.getScaleList(this.valueSchool, '2')

          this.getData()
        }
      })
    },

    // 获取时间范围
    getDateList() {
      let newUserInfo = getStore({name: 'newUserInfo'})
      let params = {
        provinceCode: newUserInfo.provinceCode,
        cityCode: newUserInfo.cityCode
      }
      return new Promise((resolve) => {
        getDateList(params).then(res => {
          if (res.data.code === 200) {
            res.data.data.unshift({id: '', surveyName: '全部'})
            this.optionsTime = res.data.data
            this.valueTime = res.data.data[0].id
            this.selectTime = res.data.data[0]
          }
          resolve();
        })
      })
    },
    // 选择时间（完成数）
    selectChangeTime() {
      console.log('this.valueTime', this.valueTime)
      this.optionsTime.forEach(item => {
        if (item.id == this.valueTime) {
          this.selectTime = item
        }
      })
      this.isShow2 = false
      this.isShow6 = false
      // this.isShow8 = false
      this.isShow1 = false
      this.isShow7 = false
      // this.isShow9 = false
      // this.isShow10 = false
      // this.isShow12 = false
      // this.isShow13 = false
      // this.isShow14 = false
      this.isShow19 = false
      this.isShow20 = false
      this.$refs.titleData.getData();
      this.getData()
    },
    // 完成数 选择时间段
    async selectChangePeriod() {
      this.isShow2 = false
      this.isShow6 = false
      // this.isShow8 = false
      // 整体完成数曲线图
      await this.getStatisticDayCount()
      // 各区完成数排名柱图(完成数)
      await this.getStatisticAreaCountAndRate()
      // 学校完成数排名(横轴完成数、纵轴学校)（完成数）
      // await this.getStatisticSchoolCountAndRate()
      await this.getTrue()
    },
    // 完成率 选择时间段
    async selectChangePeriod1() {
      this.isShow1 = false
      this.isShow7 = false
      // this.isShow9 = false
      // 完成率曲线图
      await this.statisticDayRate()
      // 各区完成数排名柱图(完成率)
      await this.getStatisticAreaCountAndRate1()
      // 学校完成数排名(横轴完成数、纵轴学校)（完成率）
      // await this.getStatisticSchoolCountAndRate1()
      // mapData
      this.$refs.mapData.getStatisticCountByArea();
      await this.getTrue()
    },
    // 小学  选择性别
    async selectChangeSex(school) {
      if (school == '小学') {
        // this.isShow10 = false
        // this.isShow12 = false
        // this.isShow13 = false
        // this.isShow14 = false
        // await this.getStatisticFactorLevel('小学')
        // await this.getStatisticLevelCountByFactor1('小学')
        // await this.getStatisticLevelCountByFactor2('小学')
        // await this.getStatisticLevelCountByFactor3('小学')
      } else if (school == '初中') {
        // this.isShow15 = false
        // this.isShow16 = false
        // this.isShow17 = false
        // this.isShow18 = false
        // await this.getStatisticFactorLevel('初中')
        // await this.getStatisticLevelCountByFactor1('初中')
        // await this.getStatisticLevelCountByFactor2('初中')
        // await this.getStatisticLevelCountByFactor3('初中')
      } else if (school == '更多') {
        this.isShow19 = false
        this.isShow20 = false
        // this.isShow21 = false
        // this.isShow22 = false
        await this.getStatisticFactorLevelMore()
        await this.getStatisticLevelCountByFactorMore1()
        // await this.getStatisticLevelCountByFactorMore2()
        // await this.getStatisticLevelCountByFactorMore3()
      }
      await this.getTrue()
    },
    // 整体完成数曲线图
    getStatisticDayCount() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          filterCondition: this.selectTime,
          // studentLevel: this.valuePeriod1
        }
        statisticDayCount(params).then(res => {
          if (res.data.code === 200) {

            this.echartsData2 = {
              ...res.data.data,
              xAxisData: res.data.data.dayDate,
              seriesData: res.data.data.recordsCount,
              name: '该年级整体完成数',
              legendData: ['数量']
            };
            console.log('222222222222222')
            // this.isShow1 = true
            // this.isShow2 = true
          }
          resolve();
        })
      })
    },
    // 整体完成数整体完成率
    statisticDayRate() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          filterCondition: this.selectTime,
          // studentLevel: this.valuePeriod2
        }
        statisticDayRate(params).then(res => {
          if (res.data.code === 200) {
            this.echartsData1 = {
              ...res.data.data,
              xAxisData: res.data.data.dayDate,
              seriesData: res.data.data.rate,
              name: '该年级整体累计完成率',
              legendData: ['完成率']
            };
            // this.isShow1 = true
            // this.isShow2 = true
          }
          resolve();
        })
      })
    },
    // 小学完成率
    getStatisticLevelRate1() {
      let newUserInfo = getStore({name: 'newUserInfo'})
      let params = {
        provinceCode: newUserInfo.provinceCode,
        cityCode: newUserInfo.cityCode,
        studentLevel: '小学'
      }
      statisticLevelRate(params).then(res => {
        if (res.data.code === 200) {
          this.echartsData3 = {
            ...res.data.data,
            xAxisData: res.data.data.dayDate,
            seriesData: res.data.data.rate,
            name: '小学完成率',
            legendData: ['完成率']
          };
          this.isShow3 = true
        }
      })
    },
    // 初中完成率
    getStatisticLevelRate2() {
      let newUserInfo = getStore({name: 'newUserInfo'})
      let params = {
        provinceCode: newUserInfo.provinceCode,
        cityCode: newUserInfo.cityCode,
        studentLevel: '初中'
      }
      statisticLevelRate(params).then(res => {
        if (res.data.code === 200) {
          this.echartsData4 = {
            ...res.data.data,
            xAxisData: res.data.data.dayDate,
            seriesData: res.data.data.rate,
            name: '初中完成率',
            legendData: ['完成率']
          };
          this.isShow4 = true
        }
      })
    },
    // 高中完成率
    getStatisticLevelRate3() {
      let newUserInfo = getStore({name: 'newUserInfo'})
      let params = {
        provinceCode: newUserInfo.provinceCode,
        cityCode: newUserInfo.cityCode,
        studentLevel: '幼儿园'
      }
      statisticLevelRate(params).then(res => {
        if (res.data.code === 200) {
          this.echartsData5 = {
            ...res.data.data,
            xAxisData: res.data.data.dayDate,
            seriesData: res.data.data.rate,
            name: '高中完成率',
            legendData: ['完成率']
          };
          this.isShow5 = true
        }
      })
    },
    // 各区完成数排名柱图（完成数）
    getStatisticAreaCountAndRate() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          filterCondition: this.selectTime,
          // studentLevel: this.valuePeriod1
        }
        statisticClassesCountAndRate(params).then(res => {
          if (res.data.code === 200) {
            this.echartsData6 = {
              ...res.data.data,
              xAxisData: res.data.data.bj_name,
              seriesData: res.data.data.total,
              name: '该校各班级完成数排名',
              legendData: ['数量']
            };
            // this.isShow6 = true

          }
          resolve();
        })
      })
    },
    // 各区完成数排名柱图(完成率)
    getStatisticAreaCountAndRate1() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          filterCondition: this.selectTime,
          // studentLevel: this.valuePeriod2
        }
        statisticClassesCountAndRate(params).then(res => {
          if (res.data.code === 200) {
            this.echartsData7 = {
              ...res.data.data,
              xAxisData: res.data.data.bj_name,
              seriesData: res.data.data.rate,
              name: '该校各班级完成率排名',
              legendData: ['完成率']
            };
            // this.isShow7 = true
          }
          resolve();
        })
      })
    },
    // 学校完成数排名(横轴完成数、纵轴学校)（完成数）
    getStatisticSchoolCountAndRate() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          filterCondition: this.selectTime,
          studentLevel: this.valuePeriod1
        }
        statisticSchoolCountAndRate(params).then(res => {
          if (res.data.code === 200) {
            this.echartsData8 = {
              ...res.data.data,
              xAxisData: res.data.data.xxName,
              seriesData: res.data.data.total,
              name: '学校完成数排名',
              legendData: ['数量']
            };
            // this.isShow8 = true
          }
          resolve();
        })
      })
    },
    // 学校完成数排名(横轴完成数、纵轴学校)（完成率）
    getStatisticSchoolCountAndRate1() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          filterCondition: this.selectTime,
          studentLevel: this.valuePeriod2
        }
        statisticSchoolCountAndRate(params).then(res => {
          if (res.data.code === 200) {

            this.echartsData9 = {
              ...res.data.data,
              xAxisData: res.data.data.xxName,
              seriesData: res.data.data.rate,
              name: '各学校完成率排名',
              legendData: ['完成率']
            };
            // this.isShow9 = true
          }
          resolve();
        })
      })
    },
    // 小学生心理健康量表各维度的统计
    getStatisticFactorLevel(studentLevel) {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = studentLevel == '小学' ? this.valueSex : this.valueSex1
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          studentLevel: studentLevel,
          filterCondition: this.selectTime,
        }
        statisticFactorLevel(params).then(res => {
          if (res.data.code === 200) {
            if (studentLevel == '小学') {
              this.echartsData10 = {
                seriesData: res.data.data,
                name: '小学生心理健康量表各维度的统计'
              };
            } else if (studentLevel == '初中') {
              this.echartsData15 = {
                seriesData: res.data.data,
                name: '中学生的心理健康量表各维度的统计'
              };
            }
            // this.isShow10 = true
          }
          resolve();
        })
      })
    },
    // 获取量表下拉数据
    getTemplateList() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
        }
        getTemplateList(params).then(res => {
          if (res.data.code === 200) {
            this.optionsSchool = res.data.data
            this.valueSchool = this.optionsSchool[0].template_id

            this.getScaleList(this.valueSchool, '2')
          }
          resolve();
        })
      })
    },

    // 获取因子列表
    getScaleList(school, type) {
      console.log('this.selectTime', this.selectTime)
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          filterCondition: this.selectTime,
          templateId: school,
        }
        getScaleList(params).then(res => {
          if (res.data.code === 200) {
            if (type == 1) {
              // 151：小学  150：初中
              if (school == '151') {
                this.options = res.data.data
              } else if (school == '150') {
                this.options1 = res.data.data
              }
            } else {
              this.options3 = res.data.data
            }


          }
          resolve();
        })
      })
    },
    // 选择因子
    async selectChange(school) {
      console.log('school', school)
      if (school == '小学') {
        // this.isShow12 = false
        // this.isShow13 = false
        // this.isShow14 = false
        // await this.getStatisticLevelCountByFactor1('小学')
        // await this.getStatisticLevelCountByFactor2('小学')
        // await this.getStatisticLevelCountByFactor3('小学')
      } else if (school == '初中') {
        // this.isShow16 = false
        // this.isShow17 = false
        // this.isShow18 = false
        // await this.getStatisticLevelCountByFactor1('初中')
        // await this.getStatisticLevelCountByFactor2('初中')
        // await this.getStatisticLevelCountByFactor3('初中')
      } else if (school == '更多') {
        this.isShow20 = false
        // this.isShow21 = false
        // this.isShow22 = false
        await this.getStatisticLevelCountByFactorMore1()
        // await this.getStatisticLevelCountByFactorMore2()
        // await this.getStatisticLevelCountByFactorMore3()
      }
      await this.getTrue()

    },
    // 根据因子统计各个区各个等级数量
    getStatisticLevelCountByFactor1(studentLevel) {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = studentLevel == '小学' ? this.valueSex : this.valueSex1
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          // studentLevel: studentLevel,
          templateId: studentLevel == '小学' ? '151' : '150',
          factorArea: 'classes',
          filterCondition: this.selectTime,
          scaleId: studentLevel == '小学' ? this.value : this.value1
        }
        statisticLevelCountByFactor(params).then(res => {
          if (res.data.code === 200) {
            if (studentLevel == '小学') {
              this.echartsData12 = {
                seriesData: res.data.data,
                name: '小学生心理健康量表各区因子统计'
              };
            } else if (studentLevel == '初中') {
              this.echartsData16 = {
                seriesData: res.data.data,
                name: '中学生心理健康量表各区因子统计'
              };
            }

            // this.isShow12 = true
          }
          resolve();
        })
      })
    },
    // 根据因子统计各个学校各个等级数量
    getStatisticLevelCountByFactor2(studentLevel) {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = studentLevel == '小学' ? this.valueSex : this.valueSex1
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          // studentLevel: studentLevel,
          templateId: studentLevel == '小学' ? '151' : '150',
          factorArea: 'classes',
          filterCondition: this.selectTime,
          scaleId: studentLevel == '小学' ? this.value : this.value1
        }
        statisticLevelCountByFactor(params).then(res => {
          if (res.data.code === 200) {
            if (studentLevel == '小学') {
              this.echartsData13 = {
                seriesData: res.data.data,
                name: '小学生心理健康量表各学校因子统计'
              };
            } else if (studentLevel == '初中') {
              this.echartsData17 = {
                seriesData: res.data.data,
                name: '中学生心理健康量表各学校因子统计'
              };
            }
            // this.isShow13 = true
          }
          resolve();
        })
      })
    },

    // 根据因子统计各个年级各个等级数量
    getStatisticLevelCountByFactor3(studentLevel) {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = studentLevel == '小学' ? this.valueSex : this.valueSex1
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          // studentLevel: studentLevel,
          templateId: studentLevel == '小学' ? '151' : '150',
          factorArea: 'classes',
          filterCondition: this.selectTime,
          scaleId: studentLevel == '小学' ? this.value : this.value1
        }
        statisticLevelCountByFactor(params).then(res => {
          if (res.data.code === 200) {
            if (studentLevel == '小学') {
              this.echartsData14 = {
                seriesData: res.data.data,
                name: '小学生心理健康量表各年级因子统计'
              };
            } else if (studentLevel == '初中') {
              this.echartsData18 = {
                seriesData: res.data.data,
                name: '中学生心理健康量表各年级因子统计'
              };
            }
            // this.isShow14 = true
          }
          resolve();
        })
      })
    },

    // 心理健康量表各维度的统计
    getStatisticFactorLevelMore() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = this.valueSex2
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          templateId: this.valueSchool,
          filterCondition: this.selectTime,
        }
        statisticFactorLevel(params).then(res => {
          if (res.data.code === 200) {
            let name = ''
            this.optionsSchool.forEach((item) => {
              if (item.template_id == this.valueSchool) {
                name = item.template_name
              }
            })
            this.echartsData19 = {
              seriesData: res.data.data,
              name: name + '筛查结果'
            };

            // this.isShow10 = true
          }
          resolve();
        })
      })
    },

    // 根据因子统计各个区各个等级数量
    getStatisticLevelCountByFactorMore1() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = this.valueSex2
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          njId: newUserInfo.njId,
          templateId: this.valueSchool,
          factorArea: 'classes',
          filterCondition: this.selectTime,
          scaleId: this.value2
        }
        statisticLevelCountByFactor(params).then(res => {
          if (res.data.code === 200) {
            let name = ''
            this.optionsSchool.forEach((item) => {
              if (item.template_id == this.valueSchool) {
                name = item.template_name
              }
            })
            this.echartsData20 = {
              seriesData: res.data.data,
              name: name + '各区筛查结果'
            };

            // this.isShow12 = true
          }
          resolve();
        })
      })
    },
    // 根据因子统计各个学校各个等级数量
    getStatisticLevelCountByFactorMore2() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = this.valueSex2
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          templateId: this.valueSchool,
          factorArea: 'school',
          filterCondition: this.selectTime,
          scaleId: this.value2
        }
        statisticLevelCountByFactor(params).then(res => {
          if (res.data.code === 200) {
            let name = ''
            this.optionsSchool.forEach((item) => {
              if (item.template_id == this.valueSchool) {
                name = item.template_name
              }
            })
            this.echartsData21 = {
              seriesData: res.data.data,
              name: name + '各学校因子统计'
            };
            // this.isShow13 = true
          }
          resolve();
        })
      })
    },

    // 根据因子统计各个年级各个等级数量
    getStatisticLevelCountByFactorMore3() {
      return new Promise((resolve) => {
        let newUserInfo = getStore({name: 'newUserInfo'})
        this.selectTime.sex = this.valueSex2
        let params = {
          provinceCode: newUserInfo.provinceCode,
          cityCode: newUserInfo.cityCode,
          areaCode: newUserInfo.areaCode,
          xxId: newUserInfo.xxId,
          templateId: this.valueSchool,
          factorArea: 'classes',
          filterCondition: this.selectTime,
          scaleId: this.value2
        }
        statisticLevelCountByFactor(params).then(res => {
          if (res.data.code === 200) {
            let name = ''
            this.optionsSchool.forEach((item) => {
              if (item.template_id == this.valueSchool) {
                name = item.template_name
              }
            })
            this.echartsData22 = {
              seriesData: res.data.data,
              name: name + '各年级因子统计'
            };
            // this.isShow14 = true
          }
          resolve();
        })
      })
    },
  }

}
</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  padding-bottom: 48px;

  .selectBox {
    display: flex;
    width: 85%;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;

    .selectText {
      margin-right: 1%
    }
  }

  .titleBox {
    background-color: #FFFFFF;
    width: 100%;
    border-radius: 5px;
    padding-top: 5px;
  }

  .blockBox {
    margin-top: 10px;
    background-color: #FFFFFF;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    width: 100%;
    border-radius: 5px;
    padding: 15px 0;

  }

  .moreIconBox {
    cursor: pointer;
    display: flex;
    width: 85%;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;

    .moreIcon {
      height: 30px;
      width: 100%;
      border-bottom: 1px solid #C0C4CC;
      border-top: 1px solid #C0C4CC;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      color: #C0C4CC;
    }
  }

  .moreBox {
    width: 100%;
    padding-bottom: 48px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around
  }
}


</style>
